package com.jair.tools;

import org.apache.poi.ss.usermodel.Cell;

public class CellUtils {
	
	public static String getCellValue(Cell cell){
		String value = null;
		if (cell != null) {
			switch (cell.getCellType()) {

				case Cell.CELL_TYPE_FORMULA:
					value = "FORMULA value=" + cell.getCellFormula();
					break;

				case Cell.CELL_TYPE_NUMERIC:
					value = "NUMERIC value=" + cell.getNumericCellValue();
					break;

				case Cell.CELL_TYPE_STRING:
					value = "STRING value=" + cell.getStringCellValue();
					break;

				case Cell.CELL_TYPE_BLANK:
					value = "<BLANK>";
					break;
				case Cell.CELL_TYPE_BOOLEAN:
					value = "BOOLEAN value-" + cell.getBooleanCellValue();
					break;

				case Cell.CELL_TYPE_ERROR:
					value = "ERROR value=" + cell.getErrorCellValue();
					break;

				default:
					value = "UNKNOWN value of type " + cell.getCellType();
			}
			System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE="
					+ value);
		}
		return value;
	}
}
